package com.siwei.mes.enums;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;

import java.util.Arrays;

/**
 * 检测类型枚举
 *
 * @Description: 检测类型枚举   0-常规 10-月检  20-季检  30-半年检  40-年检
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/7/18 10:12
 */
@Getter
public enum CheckTypeEnum {
    DEFAULT_CHECK(0, "常规"),
    MONTH_CHECK(10, "月检"),
    QUARTER_CHECK(20, "季检"),
    HALF_YEAR_CHECK(30, "半年检"),
    YEAR_CHECK(40, "年检"),
    ;
    @ApiModelProperty(name = "对应code")
    private final Integer code;

    @ApiModelProperty(value = "描述")
    private final String name;

    CheckTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code查找信息
     *
     * @param code 物料类型
     * @return
     */
    public static CheckTypeEnum selectByCode(Integer code) {
        return Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
    }
}
